"""
封装获取测试数据方法
"""

import yaml
import os
import json
from common.consts import DATA_PATH


def get_data_notes(file):
    """
    根据yaml文件返回数据
    """
    with open(file,encoding='utf-8') as f:
        data = yaml.safe_load(f)
        return data,[c.get('title') for c in data]


def get_data_only(file):
    """
    根据yaml文件返回数据
    """
    with open(file,encoding='utf-8') as f:
        data = yaml.safe_load(f)
        return data

    
    
def read_json(file_path):
    """读取json文件，以字典格式返回，同时返回ids"""
    with open(file=file_path, mode='r') as f:
        res = json.load(f)
    return res, [i['title'] for i in res]


def read_json_no_ids(file_path):
    """读取json文件，以字典格式返回，不返回ids"""
    with open(file=file_path, mode='r') as f:
        res = json.load(f)
    return res
    
